home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode New for 1.6 / CompressedPixmapSample / Source / Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-18  |  3.3 KB  |  214 lines  |  [TEXT/CWIE]

  1. /****************************/
  2. /*        MENUS             */
  3. /****************************/
  4.  
  5.  
  6. /***************/
  7. /* EXTERNALS   */
  8. /***************/
  9. #include <Dialogs.h>
  10. #include <Menus.h>
  11. #include <ToolUtils.h>
  12. #include <Devices.h>
  13.  
  14. #include "mymenus.h"
  15. #include "misc.h"
  16. #include "process.h"
  17. #include "3dmf.h"
  18.  
  19. extern    QD3DSetupOutputType    gModelViewInfo;
  20.  
  21.  
  22. /******************/
  23. /*  PROTOTYPES    */
  24. /******************/
  25.  
  26. static void HandleSpecialMenuChoice(short theItem);
  27.  
  28.  
  29. /****************************/
  30. /*    CONSTANTS             */
  31. /****************************/
  32.  
  33.                                     // MENU BAR ITEMS //
  34. #define    NOT_A_NORMAL_MENU    -1
  35. #define    APPLE_MENU_ID        400
  36. #define    FILE_MENU_ID        401
  37. #define EDIT_MENU_ID        402
  38. #define SPECIAL_MENU_ID        128
  39.  
  40.  
  41.                                     // EDIT MENU ITEMS //
  42.                                     
  43. enum
  44. {
  45.     UNDO_ITEM    =    1,
  46.     CUT_ITEM    =    3,
  47.     COPY_ITEM    =    4,    
  48.     PASTE_ITEM    =    5,
  49.     CLEAR_ITEM    =    6
  50. };
  51.  
  52.                                     // FILE MENU ITEMS //
  53. enum
  54. {
  55.     SAVE_ITEM    = 1,
  56.     QUIT_ITEM    = 3
  57. };
  58.  
  59.  
  60.                                     // APPLE MENU ITEMS //
  61. enum                                    
  62. {                                    
  63.     ABOUT_ITEM = 1,
  64.     HELP_ITEM = 2
  65. };
  66.  
  67.  
  68.  
  69. /**********************/
  70. /*     VARIABLES      */
  71. /**********************/
  72.  
  73. MenuHandle    gAppleMenu;
  74.  
  75.  
  76. /******************/
  77. /* INIT MENU BAR  */
  78. /******************/
  79.  
  80. void InitMenuBar(void)
  81. {
  82. Handle    myMenuBar;
  83.         
  84.                     /* ALLOCATE MAIN MENU BAR */
  85.     
  86.     if ((myMenuBar    =    GetNewMBar(400)) == nil)
  87.             DoFatalAlert("\pWhered the menu bar go?!");;
  88.     SetMenuBar(myMenuBar);
  89.     
  90.                     /* SET APPLE MENU */
  91.  
  92.     if ((gAppleMenu    =    GetMenuHandle(400)) == nil)
  93.             DoFatalAlert("\pGetMHandle failed!");
  94.     AppendResMenu (gAppleMenu, 'DRVR');                        // APPEND DESK ACCESSORIES
  95.     
  96.     DrawMenuBar();
  97. }
  98.  
  99.  
  100. /***************************/
  101. /* HANDLE MENU BAR CHOICE  */
  102. /***************************/
  103.  
  104. void HandleMenuChoice(long menuChoice)
  105. {
  106. short    theMenu;
  107. short    theItem;
  108.         
  109.     if    (menuChoice != 0)
  110.     {
  111.         theMenu    =    HiWord(menuChoice);
  112.         theItem    =    LoWord(menuChoice);
  113.         switch    (theMenu)
  114.         {
  115.             case    APPLE_MENU_ID:
  116.                     HandleAppleChoice(theItem);
  117.                     break;
  118.                     
  119.             case    FILE_MENU_ID:
  120.                     HandleFileChoice(theItem);
  121.                     break;
  122.                     
  123.             case    EDIT_MENU_ID:
  124.                     HandleEditChoice(theItem);
  125.                     break;
  126.                     
  127.             case    SPECIAL_MENU_ID:
  128.                     HandleSpecialMenuChoice(theItem);
  129.                     break;
  130.                     
  131.         }
  132.         HiliteMenu(0);
  133.     }
  134. }
  135.  
  136.  
  137. /*****************************/
  138. /* HANDLE APPLE MENU CHOICE  */
  139. /*****************************/
  140.  
  141. void HandleAppleChoice(short theItem)
  142. {
  143. Str255    accName;
  144. short        accNumber;
  145.         
  146.     switch    (theItem)
  147.     {
  148.         case    ABOUT_ITEM:
  149.         
  150.                 Alert(402,nil);
  151.                 break;
  152.         case    HELP_ITEM:
  153.                 Alert(128,nil);
  154.                 break;
  155.             
  156.         default:
  157.                 GetMenuItemText(gAppleMenu,theItem,accName);
  158.                 accNumber    =    OpenDeskAcc(accName);
  159.                 break;
  160.     }
  161. }
  162.  
  163. /****************************/
  164. /* HANDLE FILE MENU CHOICE  */
  165. /****************************/
  166.  
  167. void HandleFileChoice(short theItem)
  168. {
  169.     switch(theItem)
  170.     {
  171.         case    SAVE_ITEM:
  172.                 Save3DMFModel(&gModelViewInfo, nil, DrawTheGeometry);
  173.                 break;                
  174.  
  175.         case    QUIT_ITEM:
  176.                 QD3D_DisposeWindowSetup(&gModelViewInfo);
  177.                 DisposeWindow(gModelViewInfo.window);
  178.                 CleanQuit();
  179.     }
  180. }
  181.  
  182.  
  183. /****************************/
  184. /* HANDLE SPECIAL MENU CHOICE  */
  185. /****************************/
  186.  
  187. static void HandleSpecialMenuChoice(short theItem)
  188. {
  189.     switch(theItem)
  190.     {            
  191.         case    1:
  192.                 SelectCompressor();
  193.                 break;
  194.         
  195.     }
  196. }
  197.  
  198.  
  199. /****************************/
  200. /* HANDLE EDIT MENU CHOICE  */
  201. /****************************/
  202.  
  203. void HandleEditChoice(short theItem)
  204. {
  205.     SystemEdit(theItem-1);
  206.         
  207.     switch(theItem)
  208.     {
  209.     }
  210. }
  211.  
  212.  
  213.  
  214.